package com.randi.generator.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.randi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * @author ziye
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("gen_table")
@ApiModel(value = "GenTable对象", description = "GenTable对象")
public class GenTable extends BaseEntity {

    @TableField(exist = false)
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "key")
    private Long key;

    @TableId(value = "table_id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "table_id")
    private Long tableId;

    @NotBlank(message = "表名称不能为空")
    @TableField(value = "`table_name`")
    @ApiModelProperty(value = "表名称")
    private String tableName;

    @NotBlank(message = "表描述不能为空")
    @TableField(value = "`table_comment`")
    @ApiModelProperty(value = "表描述")
    private String tableComment;

    @NotBlank(message = "实体类名称不能为空")
    @TableField(value = "`class_name`")
    @ApiModelProperty(value = "实体类名称(首字母大写)")
    private String className;

    @NotBlank(message = "请输入模块名称")
    @TableField(value = "`module_name`")
    @ApiModelProperty(value = "模块名称")
    private String moduleName;

    @NotBlank(message = "请输入模块名称")
    @TableField(value = "`business_name`")
    @ApiModelProperty(value = "业务名称")
    private String businessName;

    @NotBlank(message = "请输入功能名称")
    @TableField(value = "`function_name`")
    @ApiModelProperty(value = "功能名称")
    private String functionName;

    @NotBlank(message = "请输入生成路径")
    @TableField(value = "`package_name`")
    @ApiModelProperty(value = "生成路径")
    private String packageName;

    @TableField(value = "`increment_type`")
    @ApiModelProperty(value = "主键策略")
    private String incrementType;

    @TableField(exist = false)
    @ApiModelProperty(value = "主键信息")
    private GenTableColumn primaryColumn;

    @Valid
    @TableField(exist = false)
    @ApiModelProperty(value = "表列信息")
    private List<GenTableColumn> columns;

    public void setKey(Long key) {
        this.key = null;
    }

    public Long getKey() {
        return this.tableId;
    }

}
